package com.bdy.lm.taximanager.model;

import com.bdy.lm.taximanager.util.TimeUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by LM on 2016/7/20.
 */
public class LocationMessageBody {

    //报警标志
    private int alarmUrgency = 0;//紧急报警，0
    private int earlyWaring = 0;//预警,1
    private int GPSDown = 0;//卫星定位模块故障，2
    private int GPSAntennaClip = 0;//卫星定位模块故障，3
    private int GPSAntennaShort = 0;//卫星定位天线短路，4
    private int ISUUndervoltage = 0;//ISU电源欠压，5
    private int ISUPowerDown = 0;//ISU掉电，6
    private int ISULCDDown = 0;//ISU 液晶显示故障，7

    private int TTSDown = 0;//语音合成模块故障，8
    private int cameraDown = 0;//摄像头故障，9
    private int priceCounterDown = 0;//计价器故障，10
    private int evaluaterDown = 0;//评价器故障，11
    private int ADLEDDown = 0;//LED广告屏故障，12
    private int LCDDown = 0;//液晶显示屏故障，13
    private int safeDown = 0;//安全访问模块故障，14
    private int topLEDDown = 0;//LED顶灯故障，15

    private int overSpeed = 0;//超速报警,16
    private int continueDriving = 0;//连续驾驶超时，17
    private int overTimeDriving = 0;//当天累计驾驶超时，18
    private int overTimeParting = 0;//超时停车，19
    private int inoutArea = 0;//进出区域路线，20
    private int roadDrivingTimeShart = 0;//路段行驶时间不足或过长,21
    private int noDriving = 0;//禁行路段行驶，22
    private int speedSensorDown = 0;//车速传感器故障，23

    private int illegalStarting = 0;//车辆非法点火,24
    private int illegalMoving = 0;//车辆非法移位，25
    private int ISUStorageDOwn = 0;//ISU存储故障，26
    private int recordDown = 0;//录音设备故障，27
    private int priceClockError = 0;//计价器时钟差误差范围，28

    int alarm_byte_1 = alarmUrgency*128+earlyWaring*64+GPSDown*32+GPSAntennaClip*16
            +GPSAntennaShort*8+ISUUndervoltage*4+ISUPowerDown*2+ISULCDDown;
    int alarm_byte_2 = TTSDown*128+cameraDown*64+priceCounterDown*32+evaluaterDown*16
            +ADLEDDown*8+LCDDown*4+safeDown*2+topLEDDown;
    int alarm_byte_3 = overSpeed*128+continueDriving*64+overTimeDriving*32+overTimeParting*16
            +inoutArea*8+roadDrivingTimeShart*4+noDriving*2+speedSensorDown;
    int alarm_byte_4 = illegalStarting*128+illegalMoving*64+ISUStorageDOwn*32+recordDown*16
            +priceClockError*8;
    String[] alarmFlag = {Integer.toHexString(alarm_byte_1),Integer.toHexString(alarm_byte_2),
            Integer.toHexString(alarm_byte_3),Integer.toHexString(alarm_byte_4)};

    //车辆状态
    private int located = 0;//0已定位，1未定位,0
    private int northsouth = 0;//0北纬，1南纬,1
    private int westEast = 0;//0东经，1西经,2
    private int running = 0;//0运营，1停运,3
    private int appointment = 0;//0未预约，1预约,4
    private int nullToWeight = 0;//0默认，1空转重,5
    private int weightToNull = 0;//0默认，1重转空,6

    private int ACC = 0;//0ACC关，1ACC开,8
    private int noPassenger = 0;//0空车，1重车,9
    private int oilRight = 0;//0油路正常，1油路断开,10
    private int circuitRight = 0;//0电路正常，1电路断开,11
    private int doorLocked = 0;//0车门解锁，1车门加锁,12
    private int carLocked = 0;//0车辆未锁定，1车辆锁定,13
    private int reachLimitedTime = 0;//0未达到限制运营次数/时间，1已达到,14

    private int status_1 = located*128+northsouth*64+westEast*32+running*16
            +appointment*8+nullToWeight*4+weightToNull*2;
    private int status_2 = ACC*128+noPassenger*64+oilRight*32+circuitRight*16
            +doorLocked*8+carLocked*4+reachLimitedTime*2;
    private int status_3 = 0;
    private int status_4 = 0;
    String[] status = {Integer.toHexString(status_1),Integer.toHexString(status_2),
            Integer.toHexString(status_3),Integer.toHexString(status_4)};

    //经纬度
    double latitude = 39.842531;
    double longitude = 116.28744;
    double speed = 40.1;
    double direction = 90;//0~179，正北为0，正南90
    double altitude;

    //时间
    TimeUtils timeUtils = new TimeUtils();

    private Map<String, Object> locationMessageMap = new HashMap<String, Object>();
    void construct(){
        locationMessageMap.put("status_1",status_1);
        locationMessageMap.put("status_2",status_2);
        locationMessageMap.put("status_3",status_3);
        locationMessageMap.put("status_4",status_4);
        locationMessageMap.put("alarm_byte_1",alarm_byte_1);
        locationMessageMap.put("alarm_byte_2",alarm_byte_2);
        locationMessageMap.put("alarm_byte_3",alarm_byte_3);
        locationMessageMap.put("alarm_byte_4",alarm_byte_4);
        locationMessageMap.put("latitude",latitude);
        locationMessageMap.put("longitude",longitude);
        locationMessageMap.put("speed",speed);
        locationMessageMap.put("direction",direction);
        locationMessageMap.put("locationTime", timeUtils.getStampTime());
    }

    public Map<String, Object> getLocationMessageMap() {
        construct();
        return locationMessageMap;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public void setDirection(float direction) {
        this.direction = direction;
    }

    public double getLatitude() {
        return latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public double getAltitude() {
        return altitude;
    }

    public void setAltitude(double altitude) {
        this.altitude = altitude;
    }

    public double getSpeed() {
        return speed;
    }
}
